package com.spring.service.Impl;

import com.spring.dao.AccountDao;
import com.spring.service.AccountService;
import com.spring.utils.TansformThing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;


    @Autowired
    private TansformThing tansformThing;

    @Override
    public void transformMoney(String outUser, String inUser, Double money) {
         try {    // 开启事务
             tansformThing.BeginThing();
             accountDao.out(outUser, money);
             accountDao.in(inUser, money);
             // 提交事务
             tansformThing.commit();
         }catch (Exception e){
             System.out.println(e);
             tansformThing.rollBack();
         }finally {
             tansformThing.releas();
         }
    }
}


/*AOP */
